package fr.unice.progmobile.scratchpad.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class ScratchpadDB extends SQLiteOpenHelper {

	public static final String CREATE = 
			"CREATE TABLE " + 
			DBConfig.SCRATCHPADS_TABLE + " (" + 
			DBConfig.SCRATCHPADS_TABLE_ID + 
			" INTEGER PRIMARY KEY AUTOINCREMENT, " + 
			DBConfig.SCRATCHPADS_TABLE_TITLE + 
			" TEXT NOT NULL, " + 
			DBConfig.SCRATCHPADS_TABLE_DESC + 
			" TEXT, " +
			DBConfig.SCRATCHPADS_TABLE_DATE + 
			" DATE NOT NULL, " +
			DBConfig.SCRATCHPADS_TABLE_IMAGE + 
			" BLOB);\n";
	
	public static final String DROP =
			"DROP TABLE " + 
			DBConfig.SCRATCHPADS_TABLE + ";";
	
	public ScratchpadDB(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(DROP);
		db.execSQL(CREATE);
	}

}
